var assert = require('assert');
import dedupQuerystring from '../src/dedupQuerystring';

describe('dedupQuerystring', function() {
    it('should return ?foo=bar', function() {
        assert.equal(dedupQuerystring('?foo=bar'), '?foo=bar');
    });

    it('should return ?foo=bar after dedup', function() {
        assert.equal(dedupQuerystring('?foo=bar&foo=bar'), '?foo=bar');
    });

    it('should return ?foo=bar&name=tony&age=42 after dedup', function() {
        assert.equal(dedupQuerystring('?foo=bar&name=tony&age=42&foo=bar&name=peter&age=13'), '?foo=bar&name=tony&age=42');
    });

    it('should return foo=bar&name=tony&age=42 after dedup', function() {
        assert.equal(dedupQuerystring('foo=bar&name=tony&age=42&foo=bar&name=peter&age=13'), 'foo=bar&name=tony&age=42');
    });

    it('should return empty', function() {
        assert.equal(dedupQuerystring('?'), '');
    });

    it('should return empty if has no parameter', function() {
        assert.equal(dedupQuerystring(), '');
    });
    
});